package server.player;

import general.datastructures.Vector2f;

import java.util.Vector;

import client.game.Game;
import server.sprite.Sprite;

public class Player {

	protected final Game game;
	protected final ThreadGroup tg_units;
	protected final String name;
	
	protected Sprite selectedSprite = null;
	
	protected long money;
	//TODO loeschen und stattdessen fabriken benutzen
	protected final Vector2f mc_spawnpoint;
	
	public Player(Game g, ThreadGroup parent,String name, Vector2f mc_spawnpoint)
	{
		this.game = g;
		this.name = name;
		this.tg_units = new ThreadGroup(parent, name);
		this.mc_spawnpoint = mc_spawnpoint;
	}
	
	public ThreadGroup getThreadGroup()
	{
		return tg_units;
	}
	
	public Vector<Sprite> getSprites()
	{
		Thread[] threads = new Thread[tg_units.activeCount()];
		tg_units.enumerate(threads, true);
		
		Vector<Sprite> sprites = new Vector<Sprite>();
					
		for(Thread t: threads)
		{
			if(t.getClass() == Sprite.class)
			{
				sprites.add((Sprite)t);
			}
		}
		return sprites;
	}

}
